﻿using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using System.Collections.Generic;
using Huirui.Cavan.Domain.Seedwork;
using Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule;

namespace Huirui.Cavan.Domain.MainBoundedContext.StockModule
{
    #region StockIn

    /// <summary>
    /// StockIn object for NHibernate mapped table 'StockIn'.
    /// </summary>
    [Serializable]
    public class StockInOut : Persistent<string>
    {
        #region Member Variables

        protected DateTime _inOutDate;
        protected StockInOutType _type;
        protected string _sourceCode;
        protected Account _fromAccount;
        protected string _productionNumber;
        protected string _currency;
        protected decimal _currencyRate;
        protected string _supplierInvoiceNumber;
        protected string _remark;
        protected string _contact;
        protected string _contactTelephone;
        protected StockIdentifier.StockInCheckedStatus _checkedStatus;
        protected Corporation _corporation;
        protected Department _department;
        protected Employee _employee;
        protected Project _project;
        protected Supplier _supplier;
        protected Customer _customer;
        protected WareHouse _wareHouse;
        protected UserAccount _producer;
        protected IList<StockInOutDetail> _stockInOutDetails;
        
        #endregion

        #region Constructors

        public StockInOut() 
        {
            this._stockInOutDetails = new List<StockInOutDetail>();
        }

        public StockInOut(string id, DateTime inOutDate, StockInOutType type, string sourceCode, Account fromAccount, string productionNumber, string currency, decimal currencyRate, string remark, StockIdentifier.StockInCheckedStatus checkedStatus, 
            DateTime createDate, DateTime modifyDate, UserAccount editUser, Corporation corporation, Department department, Employee employee, Project project, Supplier supplier, Customer customer,
            string contact, string contactTelephone, WareHouse wareHouse)
        {
            this.Id = id;
            this._inOutDate = inOutDate;
            this._type = type;
            this._sourceCode = sourceCode;
            this._fromAccount = fromAccount;
            this._productionNumber = productionNumber;
            this._remark = remark;
            this._contact = contact;
            this._contactTelephone = contactTelephone;
            this._checkedStatus = checkedStatus;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._producer = editUser;
            this._corporation = corporation;
            this._department = department;
            this._employee = employee;
            this._project = project;
            this._supplier = supplier;
            this._customer = customer;
            this._currency = currency;
            this._currencyRate = currencyRate;
            this._wareHouse = wareHouse;
            this._stockInOutDetails = new List<StockInOutDetail>();
        }

        #endregion

        #region Public Properties


        public virtual DateTime InOutDate
        {
            get { return _inOutDate; }
            set { _inOutDate = value; }
        }

        public virtual StockInOutType Type
        {
            get { return _type; }
            set { _type = value; }
        }


        public virtual string SourceCode
        {
            get { return _sourceCode; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for SourceCode", value, value.ToString());
                _sourceCode = value;
            }
        }

        public virtual Account FromAccount
        {
            get { return _fromAccount; }
            set
            {
                _fromAccount = value;
            }
        }

        public virtual string ProductionNumber
        {
            get { return _productionNumber; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for ProductionNumber", value, value.ToString());
                _productionNumber = value;
            }
        }

        public virtual string Currency
        {
            get { return _currency; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Currency", value, value.ToString());
                _currency = value;
            }
        }

        public virtual decimal CurrencyRate
        {
            get { return _currencyRate; }
            set { _currencyRate = value; }
        }

        public virtual string SupplierInvoiceNumber
        {
            get { return _supplierInvoiceNumber; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for SupplierInvoiceNumber", value, value.ToString());
                _supplierInvoiceNumber = value;
            }
        }

        public virtual string Contact
        {
            get { return _contact; }
            set
            {
                _contact = value;
            }
        }

        public virtual string ContactTelephone
        {
            get { return _contactTelephone; }
            set
            {
                _contactTelephone = value;
            }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual StockIdentifier.StockInCheckedStatus CheckedStatus
        {
            get { return _checkedStatus; }
            set { _checkedStatus = value; }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual Department Department
        {
            get { return _department; }
            set { _department = value; }
        }

        public virtual Employee Employee
        {
            get { return _employee; }
            set { _employee = value; }
        }

        public virtual Project Project
        {
            get { return _project; }
            set { _project = value; }
        }

        public virtual Supplier Supplier
        {
            get { return _supplier; }
            set { _supplier = value; }
        }

        public virtual Customer Customer
        {
            get { return _customer; }
            set { _customer = value; }
        }

        public virtual WareHouse WareHouse
        {
            get { return _wareHouse; }
            set { _wareHouse = value; }
        }

        public virtual UserAccount Producer
        {
            get { return _producer; }
            set { _producer = value; }
        }

        public virtual IList<StockInOutDetail> StockInOutDetails
        {
            get
            {
                if (_stockInOutDetails == null)
                {
                    _stockInOutDetails = new List<StockInOutDetail>();
                }
                return _stockInOutDetails;
            }
            set { _stockInOutDetails = value; }
        }

        #endregion
    }
    #endregion
}